package scuts.core;

/**
 * ...
 * @author 
 */

class ReverseArray {
	public static function reverseCopy <A> (a:Array<A>):Array<A>
	{
		var c = a.length;
		var res = [];
		for (e in a) {
			res[--c] = e;
		}
		return res;
	}
}

class ReverseIterator {
  // reverse on iterators is slow, because it builds up a new 
  // iterable
	public static function reverseCopy <A> (a:Iterator<A>):Iterator<A>
	{
    var res = [];
    for (e in a) {
      res.push(e);
    }
    return ReverseArray.reverseCopy(res).iterator();
	}
}